# -*- coding: utf-8 -*-
"""
    .xfree.extensions.init_db
    ~~~~~~~~~~~~~~~~~~~~~
    文件描述：数据库初始化
    作者：xfree
    邮箱：cy_83k@qq.com
"""

from sqlalchemy import MetaData
from flask_sqlalchemy import SQLAlchemy

# 数据库
metadata = MetaData(
    naming_convention={
        "ix": "ix_%(column_0_label)s",
        "uq": "uq_%(table_name)s_%(column_0_name)s",
        "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
        "pk": "pk_%(table_name)s",
    }
)
db = SQLAlchemy(metadata=metadata, session_options={"future": True})
def init_db(app):
    """ 初始化数据库
    """
    db.init_app(app)

